home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best of Shareware
/
Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso
/
mac
/
DOS
/
PROGRAMG
/
ULTRA250
/
UW_HELP5.HLP
< prev
next >
Wrap
Text File
|
1992-11-03
|
31KB
|
733 lines
`co(4,7);────────────────────────── /// General Macros ────────────────────────────────`co();
UltraWin also makes extensive use of macros ( defined in UW.H ) for simple
operations that do not justify the overhead of a function, and make your
programs more readable. The following are for general use.
`co(10,1);/// hibyte`co();
#define hibyte(c) (uchar) ((c) >> 8)
Yields the most significant byte of integer c.
`co(10,1);/// lobyte`co();
#define lobyte(c) (uchar) ((c) & 0x00ff)
Yields the least significant byte of integer c.
`co(10,1);/// lower`co();
#define lower (x, y) (x < y) ? x : y
Yields the lesser of the values x and y.
`co(10,1);/// range`co();
#define range(l,b,h) ((((b) >= (l)) && ((b) <= (h))))
Yields a 1 if b is between l and h inclusive.
`co(10,1);/// swap`co();
#define swap(a,b,c) ((c) = (a), (a) = (b), (b) = (c))
Swaps the values a and b utilizing a temporary c.
`co(10,1);/// upper`co();
#define upper (x, y) (x > y) ? x : y
Yields the greater of the values x and y.
`co(4,7);────────────────────────── /// Window Macros ─────────────────────────────────`co();
Many of the things you do with windows are only accomplished with the
window macros. The macros will allow you to perform several forms of
input/output to a window, change the window attributes, move the window
cursor within the window, and more. Nearly every access performed on
a window structure can be done using these macros. We recommend the use
of these macros wherever possible as it allows us to "hide" the data
structure, a common OOP technique. A close look at these macros will
give you some insight into how UltraWin uses the window structure.
`co(10,1);/// cls`co();
#define cls() (setmem(Screen, V_cols * V_rows * 2, 0))
Clears the entire screen to black.
`co(10,1);/// mv_cs`co();
#define mv_cs(c,r,wnp) ((wnp)->csr_x = (c), (wnp)->csr_y = (r))
Moves the "soft" cursor in window wnp to the column and row c and r.
`co(10,1);/// wn_att`co();
#define wn_att(a,wnp) ((wnp)->att = (a))
Sets the window attribute in wnp to the value a.
`co(10,1);/// wn_bdratt`co();
#define wn_bdratt(a,wnp) ((wnp)->bdr_att = (a))
Sets the window border attribute in wnp to the value a. This is
the complement to the wn_att macro.
`co(10,1);/// wn_bdr_color`co();
#define wn_bdr_color(f,b,wnp) ((wnp)->bdr_att = ((b) << 4) | (f))
Sets the border foreground and background colors in window wnp. This
is the complement to the wn_color macro.
`co(10,1);/// wn_color`co();
#define wn_color(f,b,wnp) ((wnp)->att = ((b) << 4) | (f))
Sets the foreground and background colors in window wnp. This is
done by setting the window attribute accordingly.
`co(10,1);/// wn_name`co();
#define wn_name(n, wnp) ((wnp)->name = (n))
Sets the name at the top of window wnp to the string n.
`co(10,1);/// wn_name_loc`co();
#define wn_name_loc(l, wnp) ((wnp)->name_loc = (l))
Sets the location of the name in window wnp to left, right, or
centered.
`co(10,1);/// wn_read`co();
#define wn_read( wnp ) (wn_io( IN, BUFF, (wnp)))
Pulls what is actually on the screen under the window into the
window itself! This is like wn_save, but instead of pulling the
area under the window into the save/restore buffer, it pulls it
into the window.
`co(10,1);/// wn_restore`co();
#define wn_restore( wnp ) (wn_io(OUT, SAVE, (wnp)))
Restores the area saved (by the macro wn_save) under the window wnp.
`co(10,1);/// wn_rfsh`co();
#define wn_rfsh( wnp ) (wn_io(OUT, BUFF, (wnp)))
Redraws (refreshes) the window wnp.
`co(10,1);/// wn_save`co();
#define wn_save( wnp ) (wn_io( IN, SAVE, (wnp)))
Saves the area under the window wnp to the window save area for later
restoration.
`co(10,1);/// wn_get_att`co();
#define wn_get_att(wnp) ((wnp)->att)
Returns the current window attribute. (See wn_att to set).
`co(10,1);/// wn_get_bdratt`co();
#define wn_get_bdratt(wnp) ((wnp)->bdr_att)
Returns the current window border attribute. (See wn_bdratt to set).
`co(10,1);/// wn_get_bdr_style`co();
#define wn_get_bdr_style(wnp) ((wnp)->bdr_style)
Returns the current window border style. (SGL_BDR,DBL_BDR,SLD_BDR,DUAL_BDR)
`co(10,1);/// wn_set_bdr_style`co();
#define wn_set_bdr_style(state,wnp) ((wnp)->bdr_style = state)
Sets the window border style. You must call wn_border to redraw.
`co(10,1);/// wn_get_cols`co();
#define wn_get_cols(wnp) ((wnp)->cols)
Returns the number of columns in the window, counting any border.
NOTE: There is no set macro as the columns cannot be changed directly.
`co(10,1);/// wn_get_csr_x`co();
#define wn_get_csr_x(wnp) ((wnp)->csr_x)
Returns the window's current cursor x position.
`co(10,1);/// wn_set_csr_x`co();
#define wn_set_csr_x(x,wnp) ((wnp)->csr_x = x)
Sets the window's current cursor x position.
`co(10,1);/// wn_get_csr_y`co();
#define wn_get_csr_y(wnp) ((wnp)->csr_y)
Returns the window's current cursor y position.
`co(10,1);/// wn_set_csr_y`co();
#define wn_set_csr_y(y,wnp) ((wnp)->csr_y = y)
Sets the window's current cursor y position.
`co(10,1);/// wn_get_name_loc`co();
#define wn_get_name_loc(wnp) ((wnp)->name_loc)
Returns the window's current name location. (CENTERED,LEFT_JUST,RIGHT_JUST)
`co(10,1);/// wn_set_name_loc`co();
#define wn_set_name_loc(state,wnp) ((wnp)->name_loc = state)
Sets the window's name location. Call wn_border to redraw.
`co(10,1);/// wn_get_rows`co();
#define wn_get_rows(wnp) ((wnp)->rows)
Returns the number of rows in the window, counting any border.
NOTE: There is no set macro as the rows cannot be changed directly.
`co(10,1);/// wn_is_bell_flag`co();
#define wn_is_bell_flag(wnp) ((wnp)->bell_flag)
Returns the state of the bell process flag. If wn_st_fmt() is used, and
this bit is set, a tone is sounded when a bell character is encountered.
`co(10,1);/// wn_set_bell_flag`co();
#define wn_set_bell_flag(state,wnp) ((wnp)->bell_flag = state)
Sets the state of the bell flag.
`co(10,1);/// wn_is_bk_flag`co();
#define wn_is_bk_flag(wnp) ((wnp)->bk_flag)
Returns the state of the backspace process flag. If wn_st_fmt() is used,
and this bit is set, a backspace will cause the cursor to move back one
space and delete the character.
`co(10,1);/// wn_set_bk_flag`co();
#define wn_set_bk_flag(state,wnp) ((wnp)->bk_flag = state)
Sets the state of backspace flag.
`co(10,1);/// wn_is_bs_clear`co();
#define wn_is_bs_clear(wnp) ((wnp)->bs_clear)
Returns the state of the backspace clear flag. This is used by the
function `keyword(wn_bksp,[uw_help2.hlp]/// wn_bksp); in uw_term.c and is used for terminal emulation support.
If set, a backspace will clear the previous character, otherwise, it will
simply move back one character, leaving the character unchanged.
`co(10,1);/// wn_set_bs_clear`co();
#define wn_set_bs_clear(state,wnp) ((wnp)->bs_clear = state)
Sets the state of the backspace clear flag.
`co(10,1);/// wn_is_cr_flag`co();
#define wn_is_cr_flag(wnp) ((wnp)->cr_flag)
Returns the state of the carriage return flag. If wn_st_fmt() is used,
and this bit is set, a carriage return will cause the cursor to move to
the first column of the current row. NOTE: The cursor is not moved
to the next row. (See wn_is_lf_flag).
`co(10,1);/// wn_set_cr_flag`co();
#define wn_set_cr_flag(state,wnp) ((wnp)->cr_flag = state)
Sets the state of the carriage return flag.
`co(10,1);/// wn_is_cr_lf_flag`co();
#define wn_is_cr_lf_flag(wnp) ((wnp)->cr_lf_flag)
Returns the state of the carriage return/line feed flag. If wn_st_fmt()
is used, and this bit is set, a carriage return OR line feed will cause
the cursor to move to the first column of the next line.
`co(10,1);/// wn_set_cr_lf_flag`co();
#define wn_set_cr_lf_flag(state,wnp) ((wnp)->cr_lf_flag = state)
Sets the state of the carriage return/line feed flag.
`co(10,1);/// wn_is_csr_adv`co();
#define wn_is_csr_adv(wnp) ((wnp)->csr_adv)
Returns the state of the cursor advance flag. If this bit is set, the
window cursor is automatically adjusted as text is written in the window.
`co(10,1);/// wn_set_csr_adv`co();
#define wn_set_csr_adv(state,wnp) ((wnp)->csr_adv = state)
Sets the state of the cursor advance flag.
`co(10,1);/// wn_is_eol_wrap`co();
#define wn_is_eol_wrap(wnp) ((wnp)->eol_wrap)
Returns the state of the end-of-line flag. If this bit is set, the
window cursor is automatically wrapped to the next line when the right
most column is filled. The window will scroll if wn_is_scroll_flag
is also set.
`co(10,1);/// wn_set_eol_wrap`co();
#define wn_set_eol_wrap(state,wnp) ((wnp)->eol_wrap = state)
Sets the state of the end-of-line flag.
`co(10,1);/// wn_is_hidden`co();
#define wn_is_hidden(wnp) ((wnp)->hidden)
Returns the state of the window hidden flag. If this bit is set, the
window is completely hidden by other windows on the screen.
`co(10,1);/// wn_set_hidden`co();
#define wn_set_hidden(state,wnp) ((wnp)->hidden = state)
Sets the state of the window hidden flag. (Not typically done by user).
`co(10,1);/// wn_is_inside`co();
#define wn_is_inside(wnp) ((wnp)->inside)
Returns the state if the window inside flag. If this bit is set, the
window is bordered and text output takes place inside the border. If 0,
position 0,0 is the upper left corner of the border, not one character
to the right and down.
`co(10,1);/// wn_set_inside`co();
#define wn_set_inside(state,wnp) ((wnp)->inside = state)
Sets the state of the inside flag.
`co(10,1);/// wn_is_lf_flag`co();
#define wn_is_lf_flag(wnp) ((wnp)->lf_flag)
Returns the state of the line feed flag. If wn_st_fmt() is used, and
this bit is set, a line feed will cause the cursor to move down one line.
NOTE: The cursor is not moved to the first column. (See wn_is_cr_flag).
`co(10,1);/// wn_set_lf_flag`co();
#define wn_set_lf_flag(state,wnp) ((wnp)->lf_flag = state)
Sets the state of the line feed flag.
`co(10,1);/// wn_is_mask_on`co();
#define wn_is_mask_on(wnp) ((wnp)->mask_on)
Returns the state of the window mask flag. If set, this window is
involved in output masking.
`co(10,1);/// wn_set_mask_on`co();
#define wn_set_mask_on(state,wnp) ((wnp)->mask_on = state)
Sets the state of the mask flag. (Not typically done by user).
`co(10,1);/// wn_is_mgr_flag`co();
#define wn_is_mgr_flag(wnp) ((wnp)->mgr_flag)
Returns the state of the window manager flag. If set, the window is in
the window manager's linked list.
`co(10,1);/// wn_set_mgr_flag`co();
#define wn_set_mgr_flag(state,wnp) ((wnp)->mgr_flag = state)
Sets the state of the window manager flag. (Not typically done by user).
`co(10,1);/// wn_is_overlapped`co();
#define wn_is_overlapped(wnp) ((wnp)->overlapped)
Returns the state of the window overlapped flag. If set, another window
partially overlaps this window.
`co(10,1);/// wn_set_overlapped`co();
#define wn_set_overlapped(state,wnp) ((wnp)->overlapped = state)
Sets the state of the overlapped flag. (Not typically done by user).
`co(10,1);/// wn_is_popup`co();
#define wn_is_popup(wnp) ((wnp)->popup)
This returns the state of the window popup flag. If set, the window
is a popup window, saving the area under it for later restoration.
`co(10,1);/// wn_set_popup`co();
#define wn_set_popup(state,wnp) ((wnp)->popup = state)
Sets the state of the popup flag. (Not typically done by user).
`co(10,1);/// wn_is_scroll`co();
#define wn_is_scroll(wnp) ((wnp)->scroll)
This returns the state of the window scroll flag. If set, and csr_adv
is also set, the window will scroll when the last character of the window
is written to.
`co(10,1);/// wn_set_scroll`co();
#define wn_set_scroll(state,wnp) ((wnp)->scroll = state)
Sets the state of the scroll flag.
`co(10,1);/// wn_is_set_flag`co();
#define wn_is_set_flag(wnp) ((wnp)->set_flag)
This returns the state of the window set flag. If set, the window has
been placed on the screen.
`co(10,1);/// wn_set_set_flag`co();
#define wn_set_set_flag(state,wnp) ((wnp)->set_flag = state)
Sets the state of the window set flag. (Not typically done by user).
`co(10,1);/// wn_is_tab_flag`co();
#define wn_is_tab_flag(wnp) ((wnp)->tab_flag)
Returns the state of the tab flag. If wn_st_fmt() is used, and
this bit is set, a tab will cause the cursor to move one tab to the right.
See `keyword(Tab Stop Control,[uw_help2.hlp]/// Tab Stop Control); for information on how to set tabs.
`co(10,1);/// wn_set_tab_flag`co();
#define wn_set_tab_flag(state,wnp) ((wnp)->tab_flag = state)
Sets the state of the tab flag.
`co(10,1);/// wn_is_w_wrap`co();
#define wn_is_w_wrap(wnp) ((wnp)->w_wrap)
This returns the state of the word wrap flag. If set, and wn_st_fmt() is
used, word wrap will occur within the window.
`co(10,1);/// wn_set_w_wrap`co();
#define wn_set_w_wrap(state,wnp) ((wnp)->w_wrap = state)
Sets the state of the tab flag.
`co(4,7);─────────────────────────── /// Font/EGA Control ─────────────────────────────`co();
┌──────────────────────────────────────────────────────────────────────────┐
│ `keyword(encode_color,/// encode_color); `keyword(decode_color,/// decode_color); │
│ `keyword(load_font,/// load_font); `keyword(save_font,/// save_font); │
│ `keyword(install_font,/// install_font); `keyword(get_font_info,/// get_font_info); │
│ `keyword(blink_enable,/// blink_enable); `keyword(replicate_enable,/// replicate_enable); │
│ `keyword(set_block_ab,/// set_block_ab); `keyword(rom8x8,/// rom8x8); │
│ `keyword(rom8x14,/// rom8x14); `keyword(rom8x16,/// rom8x16); │
│ `keyword(read_palette,/// read_palette); `keyword(read_palette_all,/// read_palette_all); │
│ `keyword(write_palette,/// write_palette); `keyword(write_palette_all,/// write_palette_all); │
└──────────────────────────────────────────────────────────────────────────┘
These functions are specific to EGA/VGA boards and are advanced
features. We do not attempt to explain all the details and quirks of the
EGA/VGA video subsystems. We recommend you have some reference material
detailing the EGA/VGA video system to supplement the material presented
here.
UltraWin gives you the ability to use our own EGA/VGA fonts, or create
your own with our powerful font editor. UltraWin also lets you use a full
16 background colors, and even change the EGA/VGA palette. However, it is
not possible to actually read the palette registers on an EGA board. We
resolve this deficiency by keeping a "shadow" palette that is initialized
to the standard EGA values. When you read/write the palette registers,
you are also accessing this "shadow" area.
`co(10,1);/// encode_color`co(); `keyword(source,[UW_FONT.C]~encode_color);
Takes the individual red, green, and blue color components and encodes
them into a format suitable for the EGA/VGA palette registers, returning
this value as an integer. see also `keyword(decode_color,///decode_color);
Prototype:
void encode_color(int r, int g, int b);
Parameters:
`co(11,1); int r, g, b`co();
Integers containing each color component.
Usage:
int color, r = 2, g = 3, b = 1;
...
color = encode_color( r, g, b );
`co(10,1);/// decode_color`co(); `keyword(source,[UW_FONT.C]~decode_color);
Takes an EGA/VGA color encoded value as it would be stored in a palette
register and returns the individual Red, Green, and Blue components. See
also `keyword(encode_color,/// encode_color);
Prototype:
void decode_color(int color, int *r, int *g, int *b);
Parameters:
`co(11,1); int color;`co();
The EGA/VGA encoded color value.
`co(11,1); int *r, *g, *b`co();
Integer pointers to store each color component.
Usage:
int color, r, g, b;
color = random(64);
...
decode_color( color, &r, &g, &b );
`co(10,1);/// load_font`co(); `keyword(source,[UW_FONT.C]~load_font);
Loads a font pattern file into memory. The fonts are stored in raw
format, with no header information residing in the file. As an example,
let's say we have a file containing 256 8x14 characters. The first
character's pattern is contained in the first 14 bytes, the second in
bytes 15-28, and so on. You should either allocate the appropriate
number of bytes and pass the pointer to this function or pass the name
of a sufficiently large global array of bytes. Upon a successful load,
the function will return the number of scan lines that are in each
character, or 0 upon failure. See also `keyword(save_font,///save_font);
Prototype:
int load_font( uchar *font, char *fname );
Parameters:
`co(11,1); uchar *font;`co();
A pointer to an area large enough to hold the font pattern data.
`co(11,1); char *fname;`co();
A pointer to the filename that contains the font pattern data.
Usage:
uchar Font8x14[256][14]; /* global array */
int Scan_lines;
...
Scan_lines = load_font( Font8x14, "8x14icon.fnt");
`co(10,1);/// save_font`co(); `keyword(source,[UW_FONT.C]~save_font);
Saves a font pattern from memory into a file. This is the complement
of `keyword(load_font,/// load_font);
Prototype:
int save_font( uchar *font, char *fname, int scan_lines );
Parameters:
`co(11,1); uchar *font;`co();
A pointer to an area containing the font pattern data.
`co(11,1); char *fname;`co();
A pointer to the filename to which to save the font data.
`co(11,1); int scan_lines;`co();
The number of scan lines the font contains (typically 8/14/16).
Usage:
uchar Font8x14[256][14]; /* global array */
...
save_font( Font8x14, "8x14ICON.FNT", 14 );
`co(10,1);/// install_font`co(); `keyword(source,[UW_FONT.C]~install_font);
Installs a font loaded into memory, into the EGA/VGA bios area. Two
sets of 256 characters can be resident at one time. The "block" parameter
determines which set to install. If "setmode" is non-zero, the video mode
will be reset.
Prototype:
void install_font( uchar *font, int block, int offset, int cnt,
int scan_lines, int setmode );
Parameters:
`co(11,1); uchar *font;`co();
A pointer to an area containing the font pattern data.
`co(11,1); int block;`co();
The character set in which to load this font. (0 or 1).
`co(11,1); int offset;`co();
The character offset to load the new font data, typically 0.
`co(11,1); int cnt;`co();
The number of characters to install (max 256).
`co(11,1); int scan_lines;`co();
The number of scan_lines the font contains (typically 8/14/16).
`co(11,1); int set_mode;`co();
If non-zero, the video mode will be reset.
Usage:
uchar Font8x14[256][14]; /* global array */
...
load_font( Font8x14, "8x14icon.fnt" );
install_font( Font8x14, 1, 0, 256, 14, 0 );
`co(10,1);/// get_font_info`co(); `keyword(source,[UW_FONT.C]~get_font_info);
Returns the address, number of scan_lines and video character rows of
the current font.
Prototype:
uchar far *get_font_info( int type, int *scan_lines, int *rows );
Parameters:
`co(11,1); int type;`co();
2 - get address of ROM 8x14 font
3 - get address of ROM 8x8 font
4 - get address of second half of ROM 8x8 font
5 - get address of ROM 9x14 alternate font
6 - get address of ROM 8x16 font
7 - get address of ROM 9x16 alternate font
`co(11,1); int *scan_lines;`co();
A pointer to an integer in which to store the number of scan lines in
the current font.
`co(11,1); int *rows;`co();
A pointer to an integer in which to store the number of character rows
for the current screen mode.
Usage:
int scan_lines, rows;
uchar far *font;
...
font = get_font_info( 2, &scan_lines, &rows );
`co(10,1);/// blink_enable`co(); `keyword(source,[UW_FONT.C]~blink_enable);
Enables or disables blinking on EGA/VGA systems. When the blink bit is
disabled, all 256 possible color combinations (16 foreground, 16
background) can be displayed at one time with no blinking. If enabled,
those character cells whose background color is 8-15 will blink.
Prototype:
void blink_enable(int state);
Parameters:
`co(11,1); int state;`co();
1 to enable blink, 0 to disable blink.
Usage:
...
blink_enable(1);
`co(10,1);/// replicate_enable`co(); `keyword(source,[UW_FONT.C]~replicate_enable);
Enables or disables 9th pixel replication for the 32 characters 0xC0 -
0xDF on EGA/VGA boards. The use of this function depends on the video
card in use. Some cards (especially in monochrome modes) use a 9 pixel
wide cell, even though the font is only 8 pixels wide. This usually causes
no problem as the hardware hides this from us. However, when performing
line drawing or other operations where characters must join, a gap may
exist. The hardware is capable of replicating the 8th bit into the 9th
bit to allow for continuous characters. The hardware only does this for
the line drawing character block 0xC0 - 0xDF. In short, if you modify your
own fonts and create new borders, lines, etc. that need to be continuous,
it is recommended that you store these characters in this area and enable
replication. No other character cells will be affected.
Prototype:
void replicate_enable(int state);
Parameters:
`co(11,1); int state;`co();
1 to enable 9th pixel replication, 0 to disable replication.
Usage:
...
replicate_enable(1);
`co(10,1);/// set_block_ab`co(); `keyword(source,[UW_FONT.C]~set_block_ab);
Sets the two possible active fonts as primary and secondary. Both
blocks can be set to the same mode. For example, if we load a standard
8x14 font into block 0, and an 8x14 icon font into block 1, we might say
"set_block_ab(0,1)". This sets the 8x14 as the primary font and the icon
font as secondary. (Displayed if the background is 8-15). If
"set_block_ab(1,0)" is called, the two fonts will be effectively switched.
"Set_block_ab(0,0)" will always display the 8x14 font regardless of
attribute settings.
Prototype:
void set_block_ab(int a, int b);
Parameters:
`co(11,1); int a;`co();
0 - set font 0 as primary font, 1 - set font 0 as alternate font.
`co(11,1); int b;`co();
0 - set font 1 as primary font, 1 - set font 1 as alternate font.
Usage:
...
load_font( Font8x14, "8x14.fnt" );
install_font( Font8x14, 0, 0, 256, 14, 0 );
load_font( Font8x14, "8x14icon.fnt" );
install_font( Font8x14, 1, 0, 256, 14, 0 );
set_block_ab(0,1); /* 8x14 - block 0, 8x14icon block 1 */
`co(10,1);/// rom8x8`co(); `keyword(source,[UW_FONT.C]~rom8x8);
Loads the video BIOS 8x8 font into the desired block and optionally
resets the video mode
Prototype:
void rom8x8(int block, int setmode);
Parameters:
`co(11,1); int block;`co();
0 - load font into block 0, 1 - load font into block 1.
`co(11,1); int setmode;`co();
0 - do not reset video mode. 1- set video mode.
Usage:
...
rom8x8(0,1); /* load as primary, reset video mode */
`co(10,1);/// rom8x14`co(); `keyword(source,[UW_FONT.C]~rom8x14);
Loads the video BIOS 8x14 font into the desired block and optionally
resets the video mode.
Prototype:
void rom8x14(int block, int setmode);
Parameters:
`co(11,1); int block;`co();
0 - load font into block 0, 1 - load font into block 1.
`co(11,1); int setmode;`co();
0 - do not reset video mode. 1- set video mode.
Usage:
...
rom8x14(1,0); /* load as alternate, don't reset */
`co(10,1);/// rom8x16`co(); `keyword(source,[UW_FONT.C]~rom8x16);
Loads the video BIOS 8x16 font into the desired block and optionally
resets the video mode (VGA only).
Prototype:
void rom8x16(int block, int setmode);
Parameters:
`co(11,1); int block;`co();
0 - load font into block 0, 1 - load font into block 1.
`co(11,1); int setmode;`co();
0 - do not reset video mode. 1- set video mode.
Usage:
...
rom8x16(0,0); /* load as primary, don't reset mode */
`co(10,1);/// read_palette`co(); `keyword(source,[UW_FONT.C]~read_palette);
Reads a single palette register and returns the value. To determine the
RGB components, see `keyword(decode_color,/// decode_color); above.
Prototype:
int read_palette( int pnum );
Parameters:
`co(11,1); int pnum;`co();
The color palette index to read (0-15).
Usage:
int color;
...
color = read_palette(6);
`co(10,1);/// read_palette_all`co(); `keyword(source,[UW_FONT.C]~read_palette_all);
Reads all 16 palette registers and stores the values into the desired
area.
Prototype:
void read_palette_all( uchar *vals );
Parameters:
`co(11,1); uchar *vals;`co();
A pointer to an array (at least 16 bytes) in which to store the values.
Usage:
uchar colors[16];
...
read_palette_all(colors);
`co(10,1);/// write_palette`co(); `keyword(source,[UW_FONT.C]~write_palette);
Writes a value to a single palette register. To specify the color in
RGB components, see `keyword(encode_color,/// encode_color); above.
Prototype:
void write_palette( int pnum, uchar val );
Parameters:
`co(11,1); int pnum;`co();
The color palette index to write (0-15).
`co(11,1); uchar val;`co();
The color palette value.
Usage:
...
write_palette(6, encode_color(1,3,2));
`co(10,1);/// write_palette_all`co(); `keyword(source,[UW_FONT.C]~write_palette_all);
Writes values to all palette registers.
Prototype:
void write_palette_all( uchar *vals );
Parameters:
`co(11,1); uchar *vals;`co();
The 16 color palette values.
Usage:
char palette[16] =
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f };
...
write_palette_all(palette);
`color(RED,LIGHTGRAY);────────────────────────── /// Graphics Support ─────────────────────────────`color();
UltraWin is a unique library in that although primarily designed for
text modes it has the capability to use EGA/VGA graphic modes as well.
This is due to the flexibility of UltraWin's text output routines. It was
a fairly simple task for us to route all text output through one routine
which places one character on the screen. This does not slow down normal
text output whatsoever, as all output is routed through this special g_ch
function only when the global Graphics flag is set.
Please understand though, UltraWin does not add a graphics libarary or
any other graphics routines other than the output of a single character.
All UltraWin output is still cell based. This is no great limitation as
you can use a third-party graphics library (or the one bundled with your
compiler) to do all your lines, polygons, circles, etc. To get UltraWin
to use graphics, first use your graphics library to put the video into
either EGA 640x350x16 or VGA 640x480x16 mode and call `keyword(init_uw_graphics,/// init_uw_graphics);.
It's that easy!
Since UltraWin gives you this flexibility the library can become quite
literally hardware independent. For instance, all that would be necessary
to make UltraWin work with custom hardware ( or even a dumb terminal )
would be to write ONE routine (g_ch) that outputs a single character on
the display device, and then call init_uw_graphics. All output would then
go through g_ch. Please see `keyword(g_ch,/// g_ch); for more information.
`co(10,1);/// init_uw_graphics`co(); `keyword(source,[UW_GRAPH.C]~init_uw_graphics);
Initializes UltraWin to support EGA/VGA graphics output.
Prototype:
int init_uw_graphics( int xres, int yres, int font_rows,
int font_spacing, int seg, int off );
Parameters:
Parameters:
`co(11,1); int xres, yres`co(); - resolution in pixels for EGA/VGA
`co(11,1); int font_rows`co(); - number of scan lines for current font
`co(11,1); int font_spacing`co(); - number of scan lines between characters
`co(11,1); int seg`co(); - graphics segment (-1 sets default 0xa000)
`co(11,1); int off`co(); - graphics offset (-1 sets default 0x0000)
Usage:
...
init_uw_graphics( 640, 350, 14, 14, -1, -1 );
`co(10,1);/// g_ch`co(); `keyword(source,[UW_GRAPH.C]~g_ch);
Outputs a single character to the graphics screen. This function will
not normally be called by you. It is a very important function for those
of you interested in using UltraWin in graphic modes. All UltraWin output
will go through this routine when the Graphics flag is set. This feature
gives you the power to write your own g_ch to support other graphics
standards, dumb-terminals, and virtually any non-standard hardware.
(Please note that when the global variable G_opt is set, g_ch will not
draw if the character is already on the screen in the proper colors.)
It is very important to understand what happens here. We simply replace
output routines - no other graphics support is provided - UltraWin works
exactly as it does in text mode. It will not save/restore graphics areas
under windows - you must do this yourself, if you wish.
Also note that this function, along with get_font_info and install_font
are only compilable under the Borland compilers and Microsoft C 7.00;
previous versions of Microsoft C will not compile inline assembly. Users
of other compilers can link the provided object modules (versions compiled
under Turbo C and Microsoft C 7.00 are both supplied) into their programs
if need be. Of course if you use the library for your compiler, then it
is all automatic.
Prototype:
int g_ch( int c, int r, uchar v );
Parameters:
Parameters:
`co(11,1); int c;`co(); - col (UltraWin col 0-V_cols - 1, not pixel col).
`co(11,1); int r;`co(); - row (UltraWin row 0-V_rows - 1, not pixel row).
`co(11,1); int v;`co(); - character value (0-255).
Usage:
...
g_ch(10, 15, 'x');